/**
*      author: Y_Yao
*      created: 2025-02-15 17:04:17
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 5e3 + 7;
char a[N][N];
int fa[N],sz[N];
int n,m;
int mx;
unordered_map<int,int> mp;

int find(int x)
{
    if(fa[x] == x) return x;
    else fa[x] = find(fa[x]);
    return fa[x];
}

void Union(int u,int v)
{
    u = find(u);
    v = find(v);
    if(u == v) return;

    if(sz[u] > sz[v]) swap(u,v);

    fa[u] = v;
    sz[v] += sz[u];
    sz[u] = 0;
    mp[sz[v]]++;
    mx = max(sz[v],mx);
}

void solve()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1;i <= n * m;i++)
    {
        fa[i] = i;
        sz[i] = 1;
    }
    
    for(int i = 1;i <= n;i++)
    {   
        for(int j = 1;j <= m;j++)
        {
            if(a[i][j] != '.')
            {
                if(a[i][j] == 'L')
                {
                    for(int k = j;k >= 1;k--)
                    {
                        if(a[i][k] != '.') Union((i - 1) * m + j,(i - 1) * m + k);
                    }
                }
                if(a[i][j] == 'R')
                {
                    for(int k = j;k <= m;k++)
                    {
                        if(a[i][k] != '.') Union((i - 1) * m + j,(i - 1) * m + k);
                    }
                }
                if(a[i][j] == 'U')
                {
                    for(int k = i;k >= 1;k--)
                    {
                        if(a[k][j] != '.') Union((i - 1) * m + j,(k - 1) * m + j);
                    }
                }
                if(a[i][j] == 'D')
                {
                    for(int k = i;k <= n;k++)
                    {
                        if(a[k][j] != '.') Union((i - 1) * m + j,(k - 1) * m + j);
                    }
                }
            }
        }
    }

    cout << mx << " " << mp[mx] << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}